# Replication Package: Net vs Gross External Adjustment and Demographics

## Overview
This folder contains all files needed to replicate the analysis in "Net vs Gross External Adjustment and Demographics." The paper confirms income balance dominance (Z1=53.0*** on income_bal, trade_bal null) and a KAOPEN sign-flip (Z1 x KAOPEN=+14.9* on CA, -21.8** on income_balance). KAOPEN gates RETURNS not POSITIONS (gross position interactions all NS). The S-I relationship with demographics exhibits suppression, not mediation (-102% attenuation).

## Requirements
- Python 3.10+
- pandas, numpy, scipy, statsmodels
- Data files in data/processed/

## Structure
- `scripts/` — Analysis scripts (run in phase order)
- `src/` — Shared modules (PanelGLS estimator, data loading, country classifications)
- `data/processed/` — Processed panel data (net_gross_panel.csv)
- `output/tables/` — Generated output tables
- `paper/` — Paper manuscript and references

## Reproduction
Run scripts in numerical phase order:
```
python scripts/phase1_data_assembly.py
python scripts/phase2_net_decomposition.py
python scripts/phase3_gross_positions.py
python scripts/phase4_kaopen_gating.py
python scripts/phase5_si_mediation.py
python scripts/phase6_shapley.py
python scripts/phase7_structural_break.py
python scripts/phase8_bilateral_bridge.py
python scripts/phase9_robustness.py
```

## Data Sources
- UN World Population Prospects 2024
- IMF World Economic Outlook
- Penn World Table 10.01
- Chinn-Ito KAOPEN Index
- Lane & Milesi-Ferretti External Wealth of Nations

## Notes
- All analysis uses the 140-country expanded panel (EBA-49 + SSA-20 + EU expansion + Tier 1 expansion)
- The `src/` modules are from the multilateral/followup project and contain the expanded country lists
- fx_reserves strongest instrument signal: Z1=77-84*** across all specs
- OECD: NFA Z1=-1.64** but everything else NS; income_bal completely null
- Chow test confirms structural break on income_bal: F=34.9 (p<0.001)
- Shapley: S-I=83.9%, Z=13.5%, Gross=2.6% of CA R-squared
